package com.example.mybatisplus.ctl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.service.UserService;
import com.example.mybatisplus.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 测试分页
     *
     * @param current
     * @return
     */
    @GetMapping("/page")
    public Object page(Integer current, Integer pageSize) {
        if(current==null) {
            current = 1;
        }
        if(pageSize==null){
            pageSize=3;
        }
        Page<UserVo> page = new Page<>(current, pageSize);
        page = userService.allListByPage(page, "金旭东9");
        return page;
    }
}
